package com.pinyoumei.app.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.pinyoumei.app.R;
import com.pinyoumei.app.activity.wallet.UserBalanceBean;
import com.pinyoumei.app.bean.LuckInitBean;

import java.util.List;

public class UserBalanceAdapter extends BaseQuickAdapter<UserBalanceBean.ResultBean.UserBalanceDto, BaseViewHolder> {
    private Context context;
    private int type;
    public UserBalanceAdapter(int layoutResId, @Nullable List<UserBalanceBean.ResultBean.UserBalanceDto> data) {
        super(layoutResId, data);
    }

    public void getContext(Context context){
        this.context = context;
    }

    public void getInputType(int type){
        this.type = type;
    }

    //1余额充值成功 2余额支付成功 3账户申请提现 4账户提现失败 5团购红包收益  6开团广告收益 7开团未中退回 8智能连拼支付 9幸运转盘中奖 15余额转开心券
    // 根据这个字段取对应的图标14 开心券购买 15余额转开心券 16团购订单支付 17商品购买支付 18智能连拼支付 19未团中退回 20 开团广告红包   示例：15
    @Override
    protected void convert(BaseViewHolder helper, UserBalanceBean.ResultBean.UserBalanceDto item) {
        helper.setText(R.id.ubi_iv_title,item.getReason());
        helper.setText(R.id.ubi_iv_time,item.getAdd_time());
        TextView ubi_iv_money = helper.getView(R.id.ubi_iv_money);
        if(type == 1) {
            ubi_iv_money.setText("+" + item.getAmount());
            ubi_iv_money.setTextColor(context.getResources().getColor(R.color.color_f88128));
        }else{
            ubi_iv_money.setText("-" + item.getAmount());
            ubi_iv_money.setTextColor(context.getResources().getColor(R.color.black));
        }
        int iconType = 0;
        switch (item.getDeal_kind()){
            case 1:
                iconType = R.mipmap.icon_yezfcc;
                break;
            case 2:
                iconType = R.mipmap.icon_yezcc;
                break;
            case 3:
                iconType = R.mipmap.icon_adsadsdsa;
                break;
            case 4:
                iconType = R.mipmap.icon_zhibai;
                break;
            case 5:
                iconType = R.mipmap.icon_pthb;
                break;
            case 6:
                iconType = R.mipmap.icon_ptgghb;
                break;
            case 7:
                iconType = R.mipmap.icon_qianbi;
                break;
            case 8:
                iconType = R.mipmap.icon_zlpzc;
                break;
            case 9:
                iconType = R.mipmap.icon_xyzp;
                break;
            case 15:
                if (type == 1){
                    iconType = R.mipmap.icon_kxtq;
                }else{
                    iconType = R.mipmap.icon_yegm2;
                }

                break;
            case 14:
                iconType = R.mipmap.icon_spgm2;
                break;
            case 16:
                iconType = R.mipmap.icon_ptzc2;
                break;
            case 17:
                iconType = R.mipmap.icon_dui2;
                break;
            case 18:
                iconType = R.mipmap.icon_zlpzc2;
                break;
            case 19:
                iconType = R.mipmap.icon_wpztk2;
                break;
            case 20:
                iconType = R.mipmap.icon_ptgghb2;
                break;
            case 21:
                iconType = R.mipmap.icon_zskxq;
                break;
            case 24:
                iconType = R.mipmap.icon_xycjkxq;
                break;
//            case 25:
//                iconType = R.mipmap.;
//                break;
//            case 26:
//                iconType = R.mipmap.;
//                break;



        }
        if(iconType > 0) {
            helper.setImageDrawable(R.id.ubi_iv_icon, context.getResources().getDrawable(iconType));
        }
    }
}
